package com.lidroid.xutils.http.callback;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.cookie.SM;

/* loaded from: classes.dex */
public class DefaultHttpRedirectHandler implements HttpRedirectHandler {
    @Override // com.lidroid.xutils.http.callback.HttpRedirectHandler
    public HttpRequestBase getDirectRequest(HttpResponse httpResponse) {
        if (httpResponse.containsHeader("Location")) {
            HttpGet httpGet = new HttpGet(httpResponse.getFirstHeader("Location").getValue());
            if (httpResponse.containsHeader(SM.SET_COOKIE)) {
                httpGet.addHeader(SM.COOKIE, httpResponse.getFirstHeader(SM.SET_COOKIE).getValue());
            }
            return httpGet;
        }
        return null;
    }
}
